<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增公司')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-company-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">公司名：</label>
				<div class="col-sm-8">
					<input id="orgName" name="orgName" class="form-control" type="text" placeholder="请输入公司名称" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">公司登录码：</label>
				<div class="col-sm-8">
					<input id="companyAccount" name="companyAccount" class="form-control" type="text" placeholder="请输入机构登录码" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">公司标识：</label>
				<div class="col-sm-8">
					<input id="compId" name="compId" class="form-control" type="text" placeholder="请输入机构标识码" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">过期时间：</label>
				<div class="col-sm-8">
					<input type="text" class="time-input" id="estateData" name="estateData" placeholder="请选择过期时间" required/>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">资产上限：</label>
				<div class="col-sm-8">
					<input id="estateMoney" name="estateMoney" class="form-control" type="text" placeholder="请输入大于0的整数" required>
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">系统IP：</label>
				<div class="col-sm-8">
					<input id="estateIp" name="estateIp" class="form-control" type="text" placeholder="请输入系统IP" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">小程序IP：</label>
				<div class="col-sm-8">
					<input id="estateAppletUrl" name="estateAppletUrl" class="form-control" type="text" placeholder="请输入小程序IP" required>
				</div>
			</div>
		</form>
	</div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "estate/company"
        $("#form-company-add").validate({
            rules: {
                onkeyup: false,
                orgName: {
                    remote: {
                        url: ctx + "estate/company/checkNameUnique",
                        type: "get",
                        dataType: "json",
                        data: {
                            "orgName": function () {
                                return $.common.trim($("#orgName").val());
                            }
                        },
                        dataFilter: function (data) {
                            return $.validate.unique(data);
                        }
                    }
                },
                companyAccount: {
                    remote: {
                        url: ctx + "estate/company/checkAccountUnique",
                        type: "get",
                        dataType: "json",
                        data: {
                            "companyAccount": function () {
                                return $.common.trim($("#companyAccount").val());
                            }
                        },
                        dataFilter: function (data) {
                            return $.validate.unique(data);
                        }
                    }
                },
                compId: {
                    remote: {
                        url: ctx + "estate/company/checkCompIdUnique",
                        type: "get",
                        dataType: "json",
                        data: {
                            "compId": function () {
                                return $.common.trim($("#compId").val());
                            }
                        },
                        dataFilter: function (data) {
                            return $.validate.unique(data);
                        }
                    }
                }
            },
            messages: {
                "orgName": {
                    remote: "公司名称已经存在"
                },
                "companyAccount": {
                    remote: "公司登录码已经存在"
                },
                "compId": {
                    remote: "公司标识码已经存在"
                }
            },
            focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            $.operate.save(prefix + "/add", $('#form-company-add').serialize());
	        }
	    }
	</script>
</body>
</html>
